package setting

import (
	"github.com/spf13/viper"
	"go-caipu/pkg/infra/log"
	"strings"
)

//type Logger struct {
//	Enabled bool
//	mode    string
//	Path    string
//	Level   string
//	Console Console
//	Filters string
//	File    File
//}
//type Console struct {
//	Level  string
//	Format string
//}
//
//type File struct {
//	Level        string
//	Format       string
//	LogRotate    bool
//	MaxLines     int
//	MaxSizeShift int
//	DailyRotate  bool
//	MaxDays      int
//}

func (cfg *Cfg) loadLogger(viper *viper.Viper) error {
	logModStr := viper.Sub("logger").GetString("mode")

	logModes := strings.Split(logModStr, ",")
	// also try space
	if len(logModes) == 1 {
		logModes = strings.Split(logModStr, " ")
	}

	return log.ReadLoggingConfig(logModes, cfg.Application.LogsPath, viper)
}
